from urllib import request

response = request.urlopen('https://www.baidu.com/')
print(type(response))
print(response.read()) #文件为2进制文件
print(response.read().decode('utf-8'))  #使用utf-8编码
print(response.status) #获取响应状态
print(response.getheaders()) #获取响应头信息
print(response.getheaders('Server')) #获取响应头为Server的信息